package space.jevin.jevinboot.exception.business;

import space.jevin.jevinboot.exception.EnumErrorMessage;

/**
 * 鉴权错误码
 *
 * @author zhangjiehang
 * @version V1.0
 * @date 2021/5/11 1:34 下午
 */
public enum AccessErrorCode implements EnumErrorMessage {
    /**
     * A0300
     */
    A0300("A0300", "访问权限异常"),
    A0301("A0301", "访问未授权"),
    A0302("A0302", "正在授权中"),
    A0303("A0303", "用户授权申请被拒绝"),
    A0310("A0310", "因访问对象隐私设置被拦截"),
    A0311("A0311", "授权已过期"),
    A0312("A0312", "无权限使用API"),
    A0313("A0313", "appId与appSecret不匹配"),
    A0320("A0320", "用户访问被拦截"),
    A0321("A0321", "黑名单用户"),
    A0322("A0322", "账号已冻结"),
    A0323("A0323", "非法IP地址"),
    A0324("A0324", "网关访问受限"),
    A0325("A0325", "地域黑名单"),
    A0330("A0330", "服务已欠费"),
    A0340("A0340", "用户签名异常"),
    A0341("A0341", "RSA签名错误"),
    A0342("A0342", "AES签名错误"),
    A0350("A0350", "Token已过期"),
    A0351("A0351", "Token签名无效");

    private final String code;

    private final String error;

    AccessErrorCode(String code, String error) {
        this.code = code;
        this.error = error;
    }

    public static AccessErrorCode getValueByKey(String key) {
        for (AccessErrorCode s : AccessErrorCode.values()) {
            if (s.getCode().equals(key)) {
                return s;
            }
        }
        return null;
    }
    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return error;
    }
}
